package cn.cjj.gulimall.product.web;

import cn.cjj.gulimall.product.service.SkuInfoService;
import cn.cjj.gulimall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

/**
 * @author CuiJunJie
 * @create 2021/6/30-14:55
 */
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;


    @RequestMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {

        SkuItemVo skuItemVo = skuInfoService.getItemInfoById(skuId);

        model.addAttribute("item", skuItemVo);

        return "item";
    }
}
